﻿var salient = {};
salient.accessControl = {};

(function()
{
    var AccessControlHeader = function(value)
    {

        value = value || {};

        if (typeof (value) === "string")
        {
            value = eval(value);
        }

        this.mode = value.mode || undefined;
        this.username = value.username || undefined;
        this.password = value.password || undefined;
        this.logout = value.logout || undefined;
        this.path = value.path || undefined;
        this.rawUrl = value.rawUrl || undefined;
        this.requestType = value.requestType || undefined;
        this.unauthenticated = value.unauthenticated || undefined;
        this.authenticated = value.authenticated || undefined;
        this.loginResult = value.loginResult || undefined;
        var that = this;
        this.toJSON = function()
        {
            value = "{";
            var isFirst = true;
            for (var key in that)
            {
                if (that.hasOwnProperty(key) && typeof (that[key]) !== "undefined" && typeof (that[key]) !== "function")
                {
                    if (isFirst === false){value += ",";}                    
                    isFirst = false;
                    value += '"' + key + '":"' + that[key] + '"';
                }
            }
            value += "}";
            return value;
        }
    }

    this.AccessControlHeader = AccessControlHeader;

}).call(salient.accessControl)